import axios from '@/utils/request';

const SERVICE_API = process.env.VUE_APP_BASE_API;
const USER_API = process.env.VUE_APP_USER_API;

const getUserInfo = () => {
    return axios.get(USER_API + '/user/getUserByToken')
}

const getCategorys = (data) => {
    return axios.get(SERVICE_API + '/serviceType/list', {
        params: data
    })
}

const categorySort = (data) => {
    return axios.put(SERVICE_API + '/serviceType/sort', data)
}

const categoryDelete = (data) => {
    return axios.delete(SERVICE_API + '/serviceType/delete', data)
}

const categoryAdd = (data) => {
    return axios.post(SERVICE_API + '/serviceType/create', data)
}

const categoryEdit = (data) => {
    return axios.put(SERVICE_API + '/serviceType/update', data)
}

const getApps = (data) => {
    return axios.get(SERVICE_API + '/service/list', {
        params: data
    })
}

const appAdd = (data) => {
    return axios.post(SERVICE_API + '/service/create', data)
}

const appEdit = (data) => {
    return axios.put(SERVICE_API + '/service/update', data)
}

const appDelete = (data) => {
    return axios.delete(SERVICE_API + '/service/delete', data)
}

const appPublish = (data) => {
    return axios.post(SERVICE_API + '/service/publish', data)
}

const appOffline = (data) => {
    return axios.put(SERVICE_API + '/service/downline', data)
}

const appUpgrade = (data) => {
    return axios.post(SERVICE_API + '/service/upgrade', data)
}

const getAppDetail = (data) => {
    return axios.get(SERVICE_API + '/service/detail', {
        params: data
    })
}

const getPublishRecords = (data) => {
    return axios.get(SERVICE_API + '/service/getPublishList', {
        params: data
    })
}

const getUpgradeRecords = (data) => {
    return axios.get(SERVICE_API + '/service/getUpgradeList', {
        params: data
    })
}

const getUpgradeRecordDetail = (data) => {
    return axios.get(SERVICE_API + '/service/getUpgradeDetail', {
        params: data
    })
}

const getAuthList = (data) => {
    return axios.get(SERVICE_API + '/service/getAuthorisationList', {
        params: data
    })
}

const getCustomerList = (data) => {
    return axios.get(SERVICE_API + '/service/getCustomerList', {
        params: data
    })
}

export {
    getUserInfo,
    getCategorys,
    categorySort,
    categoryDelete,
    categoryAdd,
    categoryEdit,
    getApps,
    getAppDetail,
    appAdd,
    appEdit,
    appDelete,
    appPublish,
    appOffline,
    appUpgrade,
    getPublishRecords,
    getUpgradeRecords,
    getUpgradeRecordDetail,
    getAuthList,
    getCustomerList
}